<template>
  <div class="demo-title">chexkbox/demo6</div>
  <div class="demo">
    <CheckboxGroup v-model="val" ref="groupRef" @change="onChange">
      <Checkbox class="checkbox" label="1">Option content 1</Checkbox>
      <Checkbox class="checkbox" label="2">Option content 2</Checkbox>
      <Checkbox class="checkbox" label="3">Option content 3</Checkbox>
      <Checkbox class="checkbox" label="4">Option content 4</Checkbox>
    </CheckboxGroup>
    <div class="button">
      <Button type="primary" size="small" @click="toggleAll(true)" style="margin-right: 10px">Select all</Button>
      <Button type="info" size="small" plain @click="toggleReverse">Reversely select</Button>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import { Checkbox, CheckboxGroup } from '@sscd-mobile/checkbox'
  import Button from '@sscd-mobile/button'
  const val = ref([])
  const groupRef = ref()
  const onChange = (val) => console.log(val)
  const toggleAll = (val) => groupRef.value?.toggleAll(val)
  const toggleReverse = () => groupRef.value?.toggleReverse()
</script>

<style lang="less" scoped>
  .demo {
    padding: 12px;
    background-color: #fff;
    .checkbox {
      &:not(:first-child) {
        margin-top: 12px;
      }
    }
    .button {
      margin-top: 24px;
    }
  }
</style>
